# -*- coding: utf-8 -*-
import formencode

from cibynet.model.utils import UnicodeProperty
from cibynet.model import m_banks


class Check(object):
  """
  Attributes:
    * bank
    * number
    * issuer
  """
  
  issuer = UnicodeProperty("_issuer")
  
  def __init__(self, bank, checknumber, checkissuer, checkvalue=15):
    """
    Arguments:
      - bank: Bank object, check bank.
      - checknumber: string.
      - checkissuer: Unicode.
      - checkvalue: default to 15, in euros.
    """
    self.bank = bank
    self.number = checknumber
    self.issuer = checkissuer
    self.value = checkvalue

  
class CheckNewValidator(formencode.Schema):
  """Validate the different fields necessary to create a Check object.
  """
  allow_extra_fields = True
  filter_extra_fields = False
  bank = m_banks.BankIdValidator(not_empty=True)
  checknumber = formencode.validators.String(not_empty=True)
  checkissuer = formencode.validators.String(not_empty=True)
  
